/*
 * @Descripttion:
 * @version: 1.0.0
 * @Author: liuzicheng
 * @Date: 2025-01-22 15:08:16
 * @LastEditors: liuzicheng
 * @LastEditTime: 2025-03-05 14:14:20
 */
import Layout from "@/layouts";
import { useRoutes } from "react-router";
import treeRouter from "./handleRoute";
import ResultCom from "@/pages/components/result";
import { ErrorBoundary } from "@ant-design/pro-components";
const noLayoutRoutes = treeRouter.filter((item) => !item.meta.noLayout);

function RouterTable() {
  const routes: any = [];
  if (treeRouter.length > 0) {
    treeRouter.map((item) => {
      if (item.meta.noLayout) {
        routes.push(item);
      }
    });
    routes.unshift({
      path: "/",
      element: <Layout />,
      children: [
        ...noLayoutRoutes,
        {
          path: "/notRoles",
          element: <ResultCom status={"403"} title="403" />
        },
        {
          path: "*",
          element: <ResultCom status={"404"} title="404" />
        }
      ]
    });
  }
  // routes.push({
  // 	path: "*",
  // 	element: <Empty/>,
  // })
  // console.log(routes, "routes")

  const element = useRoutes(routes);
  return <ErrorBoundary>{element}</ErrorBoundary>;
}
export default RouterTable;

// 左侧菜单路由
export const routes = {
  path: "/",
  redirect: noLayoutRoutes[0].path,
  routes: noLayoutRoutes
};
